<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>比较两个数或对象的 key value 是否一致</title>
</head>
<body>
  <script>
    var obj1 = {
      name: 001,
      age: 18
    }
    var obj2 = {
      name: 002,
      age: 18
    }
    // key 是属性，value 是属性值
    // console.log(Object.keys(obj1), Object.values(obj1))
    if(Object.keys(obj1) == Object.keys(obj2) && Object.values(obj1) == Object.values(obj2)) {
      alert('一致')
    } else {
      alert('不一致')
    }
  </script>
</body>
</html>